﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace MixScript.BLL.FI
{
    public class rptSubsidiary : cBaseBLL
    {
        public rptSubsidiary() { }

        public DataSet GetData(int type)
        {
            DataSet ds = new DataSet();

            DataTable dt1 = new DataTable();
            DataTable dt2 = new DataTable();
            dt1 = null;
            dt2 = null;
            
            if (type == 1)
            {
                dt2 = GetSubAccount();
                //ds.Tables.Add(dt1);
                ds.Tables.Add(dt2);
            }
            else if (type == 2)
            {
                dt1 = GetSubBank();
                dt2 = GetAccBank();
                ds.Tables.Add(dt1);
                ds.Tables.Add(dt2);
            }
            else if (type == 3)
            {
                dt1 = GetSubCustomer();
                dt2 = GetAccCustomer();
                ds.Tables.Add(dt1);
                ds.Tables.Add(dt2);
            }
            else if (type == 4)
            {
                dt1 = GetSubEmployee();
                dt2 = GetAccEmployee();
                ds.Tables.Add(dt1);
                ds.Tables.Add(dt2);
            }
            else if (type == 5)
            {
                dt1 = GetSubSupplier();
                dt2 = GetAccSupplier();
                ds.Tables.Add(dt1);
                ds.Tables.Add(dt2);
            }
            return ds;

        }

        private DataTable GetSubAccount()
        {
            string sSQL = "select acctnum code ,acctname name,currency from accaccounts where type=4 and process=1 and LEN(acctnum) > 7  order by acctnum ";
            return Dbserver.ExecuteQuery(sSQL, "SubAccount");
        }
        private DataTable GetAccBank()
        {
            string sSQL = "select acctnum code ,acctname name,currency from accaccounts where process=3 order by acctnum";
            return Dbserver.ExecuteQuery(sSQL, "accBank");
        }
        private DataTable GetSubBank()
        {
            string sSQL = "select banknum code, bankname name from mst_bank order by banknum";
            return Dbserver.ExecuteQuery(sSQL, "SubBank");
        }


        private DataTable GetAccCustomer()
        {
            string sSQL = "select acctnum code ,acctname name,currency from accaccounts where process=4 order by acctnum";
            return Dbserver.ExecuteQuery(sSQL, "accCustomer");
        }
        private DataTable GetSubCustomer()
        {
            string sSQL = "select cust_code code,cust_name name from mst_customer order by cust_name";
            return Dbserver.ExecuteQuery(sSQL, "SubBank");
        }


        private DataTable GetAccEmployee()
        {
            string sSQL = "select acctnum code ,acctname name,currency from accaccounts where  process=6 order by acctnum";
            return Dbserver.ExecuteQuery(sSQL, "accCustomer");
        }
        private DataTable GetSubEmployee()
        {
            string sSQL = "select empl_id code,nama name from tb_employee  order by nama";
            return Dbserver.ExecuteQuery(sSQL, "SubBank");
        }

        private DataTable GetAccSupplier()
        {
            string sSQL = "select acctnum code ,acctname name,currency from accaccounts where  process=7 order by acctnum";
            return Dbserver.ExecuteQuery(sSQL, "accCustomer");
        }
        private DataTable GetSubSupplier()
        {
            string sSQL = "select sup_code code,sup_name name from mst_supplier order by sup_name";
            return Dbserver.ExecuteQuery(sSQL, "SubBank");
        }




    }
}
